<template>
  <div class="uniondrugAddJS">
    <router-link to="/uniondrughealthy/pagejump">
        <van-cell title="药联健康App页面跳转" value="去测试" is-link></van-cell>
      </router-link>
    <div class="top15"></div>
    <van-cell-group title="无回调方案将来会弃用">
      <van-cell title="获取设备信息" is-link @click="getDeviceInfo()" />
      <van-cell title="获取用户信息" is-link @click="getUserInfo()" />
    </van-cell-group>

    <van-cell-group title="无回调方案将来会弃用">
      <van-cell title="是否支持同屏" is-link @click="isCanSameScreen()" />
      <van-cell title="获取设备信息回调" is-link @click="getDeviceInfoBack()" />
      <van-cell title="获取用户信息回调" is-link @click="getUserInfoBack()" />
    </van-cell-group>
  </div>
</template>

<script>
import Vue from "vue";
import { Cell, CellGroup, Toast, Dialog } from "vant";
Vue.use(Cell);
Vue.use(CellGroup);
Vue.use(Toast);
Vue.use(Dialog);

export default {
  name: "UniondrugAddJS",
  components: {},
  methods: {
    getDeviceInfo() {
      if (window["UnionDrugHealthy"] == undefined) {
        Toast("不支持");
      } else {
        window["UnionDrugHealthy"].getDeviceInfo();
      }
    },
    getUserInfo() {
      if (window["UnionDrugHealthy"] == undefined) {
        Toast("不支持");
      } else {
        window["UnionDrugHealthy"].getUserInfo();
      }
    },
    isCanSameScreen() {
      if (window["UnionDrugHealthy"] == undefined) {
        Toast("不支持");
      } else {
        if (window["UnionDrugHealthy"].isCanSameScreen) {
          Dialog.alert({
            message: "支持同屏",
          }).then(() => {
            // on close
          });
        }else{
          Toast("不支持");
        }
      }
    },
    getDeviceInfoBack() {
      if (window["UnionDrugHealthy"] == undefined) {
        Toast("不支持");
      } else {
        window["UnionDrugHealthy"].getDeviceInfo(function (deviceInfo) {
          Dialog.alert({
            message: deviceInfo,
          }).then(() => {
            // on close
          });
        });
      }
    },
    getUserInfoBack() {
      if (window["UnionDrugHealthy"] == undefined) {
        Toast("不支持");
      } else {
        window["UnionDrugHealthy"].getUserInfo(function (UserInfo) {
          Dialog.alert({
            message: UserInfo,
          }).then(() => {
            // on close
          });
        });
      }
    },
  },
};

window['setDeviceInfo'] = function setDeviceInfo(deviceInfo) {
  Dialog.alert({
    message: deviceInfo,
  }).then(() => {
    // on close
  });
}

window['setUserInfo'] = function setUserInfo(UserInfo) {
  Dialog.alert({
    message: UserInfo,
  }).then(() => {
    // on close
  });
}
</script>

<style scoped>
.uniondrugAddJS {
  background-color: #f5f5f5;
}
.top15 {
  height: 0.10rem;
  background-color: #f5f5f5;
}
</style>
